<template>
  <div class="msgbox">
    <div>
      <button @click="isShow = !isShow">显示/隐藏</button>
    </div>
    <transition appear>
      <span v-show="isShow" class="msg">我是消息组件1</span>
    </transition>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow: true,
    };
  },
};
</script>

<style lang="less" scoped>
.msgbox {
  text-align: center;
}
.msg {
  display: block;
  margin-top: 50px;
  padding: 20px 0;
  background-color: pink;
}

@keyframes fade {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0px);
  }
}

.v-enter-active {
  animation: fade 1s linear;
}

.v-leave-active {
  animation: fade 1s linear reverse;
}
</style>
